public class num50 {
    public double myPow(double x, int n) {
        return n >= 0 ? quick(x,n) :1.0 / quick(x,-n);
    }

    private double quick(double x, int n) {
        if(n == 0){
            return 1.0;
        }
        double y = quick(x,n/2);
        return n % 2 == 0? y * y : y * y * x;
    }
}
